﻿using Common;
using DataLibrary;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;

namespace ImageUploader
{
    public partial class Form_Main : Form
    {
        private ImageManagerEntities ime = new ImageManagerEntities();
        private string imagePath = string.Empty;
        private string bakPath = string.Empty;
        private Hashtable workshopids = new Hashtable();
        private List<string> userSelected = new List<string>(4);
        public Form_Main()
        {
            InitializeComponent();
        }

        private void Form_Main_Load(object sender, EventArgs e)
        {
            this.tool_operator.Text = "操作员工编号：" + GetUserInfo.UserNum;
            this.tool_time.Text = "系统时间：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm");
            this.tool_Location.Text = "基地：" + GetUserInfo.Location;
            this.timer1.Interval = 1000 * 60;
            this.timer1.Start();
            AutoLoad();
            if (GetUserInfo.RoleID == 1)
                Export_ToolStripMenuItem.Enabled = true;
            cBox_format.Text = "*.jpg";
            ckBox_bulkUpload.Checked = true;
            txt_FileNum.Enabled = false;
            cBox_UploadSpeed.SelectedIndex = 1;
            ShowMsg.showMsg(listB_InfoList, tool_operator.Text + "，于系统时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "登陆系统");
            if (!Directory.Exists(System.Environment.CurrentDirectory + "\\RepeatLogs"))
                Directory.CreateDirectory(System.Environment.CurrentDirectory + "\\RepeatLogs");
            CheckUpgrade();
            if (RedisHelper.Get<List<string>>(GetUserInfo.UserNum + "Selected") != null)
            {
                List<string> list = RedisHelper.Get<List<string>>(GetUserInfo.UserNum + "Selected");
                cBox_Workshop.Text = list[0];
                cBox_MachineNo.Text = list[1];
                cBox_format.Text = list[2];
                cBox_UploadSpeed.Text = list[3];
                txt_imagePath.Text = list[4];
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.tool_time.Text = "当前系统时间：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm");
            if (listB_InfoList.Items.Count > 5000 && !txt_Num.Text.Contains("bulk"))
            {
                listB_InfoList.Items.Clear();
            }
            if (listB_ErrorList.Items.Count > 1000 && !txt_Num.Text.Contains("bulk"))
            {
                listB_ErrorList.Items.Clear();
            }
            if (txt_Num.Text.Contains("bulk"))
            {
                #region 一些显示效果
                cBox_format.Enabled = true;
                cBox_Team.Enabled = true;
                dateTimePicker1.Enabled = true;
                cBox_Workshop.Enabled = true;
                cBox_MachineNo.Enabled = true;
                txt_imagePath.Enabled = true;
                btn_imagePathSelect.Enabled = true;
                btn_start.Enabled = true;
                cBox_UploadSpeed.Enabled = true;
                //bak_ToolStripMenuItem.Enabled = false;
                ckBox_bulkUpload.Enabled = true;
                menu_ChangeUser.Enabled = true;
                VersionUpgradeToolStripMenuItem.Enabled = false;
                #endregion
            }
        }

        private void btn_start_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cBox_Workshop.Text))
            {
                MessageBox.Show("请选择车间");
                return;
            }
            if (string.IsNullOrEmpty(cBox_MachineNo.Text))
            {
                MessageBox.Show("请选择机器号");
                return;
            }
            if (string.IsNullOrEmpty(cBox_Team.Text))
            {
                MessageBox.Show("请选择班次");
                return;
            }
            if (ckBox_Remember.Checked)
            {
                userSelected.Clear();
                userSelected.Add(cBox_Workshop.Text);
                userSelected.Add(cBox_MachineNo.Text);
                userSelected.Add(cBox_format.Text);
                userSelected.Add(cBox_UploadSpeed.Text);
                //RedisHelper.Set<List<string>>(GetUserInfo.UserNum + "Selected", userSelected, DateTime.Now.AddDays(2) - DateTime.Now);
            }
            else
            {
                RedisHelper.DelKey(GetUserInfo.UserNum + "Selected");
            }
            var team = ime.Teams.Where(u => u.TeamName == cBox_Team.Text.Trim()).First();//班次
            var workshop = ime.Workshops.Where(u => u.Name == cBox_Workshop.Text.Trim()).First();//车间
            int machineNo = int.Parse(cBox_MachineNo.Text);
            var machine = ime.Machines.Where(u => u.MachineNum == machineNo && u.WorkshopID == workshop.WorkshopID).First();//机台                        
            #region 一些显示效果
            cBox_format.Enabled = false;
            cBox_Team.Enabled = false;
            dateTimePicker1.Enabled = false;
            cBox_Workshop.Enabled = false;
            cBox_MachineNo.Enabled = false;
            txt_imagePath.Enabled = false;
            btn_imagePathSelect.Enabled = false;
            btn_start.Enabled = false;
            repeat_ToolStripMenuItem.Enabled = false;
            cBox_UploadSpeed.Enabled = false;
            //bak_ToolStripMenuItem.Enabled = true;
            menu_ChangeUser.Enabled = false;
            txt_Num.Text = "0";
            ckBox_bulkUpload.Enabled = false;
            VersionUpgradeToolStripMenuItem.Enabled = false;
            #endregion
            string code = workshop.Name + "-" + team.TeamName + "-" + machine.MachineNum;
            Hashtable htCode = new Hashtable();
            htCode.Add("workshopID", workshop.WorkshopID);
            htCode.Add("teamID", team.TeamID);
            htCode.Add("machineID", machine.MachineID);
            htCode.Add("code", code);
            htCode.Add("bulk", 0);//标记是否批量上传，0-不是，1-是
            imagePath = "";
            if (ckBox_bulkUpload.Checked)
            {
                htCode["bulk"] = 1;
                string debug = string.Format("时间：{0}，员工：{1},开启了批量上传", DateTime.Now, GetUserInfo.UserNum);
                ShowMsg.showMsg(listB_InfoList, debug);
                ShowMsg.showMsg(listB_InfoList, "正在进行文件划分，如上传文件较多，该步骤会需要一些时间,请耐心等待...");
                if (!txt_imagePath.Text.Contains("合格"))
                {
                    ShowMsg.showMsg(listB_InfoList, "请选择批量文件的存储目录");
                    txt_imagePath.Text = "";
                    FolderBrowserDialog dialog = new FolderBrowserDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        txt_imagePath.Text = dialog.SelectedPath;
                    }
                    else
                    {
                        ShowMsg.showMsg(listB_ErrorList, "请选择上传路径");
                        return;
                    }
                }
                userSelected.Add(txt_imagePath.Text);
                RedisHelper.Set<List<string>>(GetUserInfo.UserNum + "Selected", userSelected, DateTime.Now.AddDays(2) - DateTime.Now);
                List<FileInfo> files = PublicMethod.GetPicFiles(txt_imagePath.Text);
                if (files.Count < 1)
                {
                    if (txt_imagePath.Text.Contains("bulk"))
                        ShowMsg.showMsg(listB_InfoList, "请等待验证完成后再次尝试上传");
                    else
                        ShowMsg.showMsg(listB_InfoList, "所选路径下没有图片文件");
                    return;
                }
                txt_FileNum.Text = files.Count().ToString();
                bakPath = string.Format(@"{0}__bak\bulk\{1}", Path.GetPathRoot(txt_imagePath.Text), htCode["code"]);
                if (!Directory.Exists(bakPath))
                    Directory.CreateDirectory(bakPath);
                htCode["bakPath"] = bakPath;
                List<string> checklist = new List<string>(files.Count);
                foreach (FileInfo file in files)
                {
                    checklist.Add(Path.GetFileNameWithoutExtension(file.Name));
                }
                int times = string.IsNullOrEmpty(cBox_UploadSpeed.Text) ? 1 : int.Parse(cBox_UploadSpeed.Text.Substring(0, 1));
                if (SplitFiles(txt_imagePath.Text, times))
                {
                    Common.MonitorFile.bulkUpload(txt_imagePath.Text, listB_InfoList, listB_ErrorList, htCode, txt_Num, checklist, times);
                }
                else
                    Common.MonitorFile.bulkUpload(txt_imagePath.Text, listB_InfoList, listB_ErrorList, htCode, txt_Num, checklist, 1);
                RedisHelper.Set<List<string>>("checkBulk", null, DateTime.Now.AddHours(12) - DateTime.Now);//设定一个初始值，确保改key一直存在                
            }
            else
            {
                if (string.IsNullOrEmpty(txt_imagePath.Text))
                {
                    DriveInfo[] allDrives = DriveInfo.GetDrives();
                    foreach (DriveInfo item in allDrives)
                    {
                        if (item.IsReady)
                        {
                            if (!item.Name.Contains("C") && item.TotalFreeSpace > (long)1024 * 1024 * 1024 * 10)
                            {
                                imagePath = string.Format(@"{0}测试图片\{1}-{2}", item.Name, DateTime.Now.ToString("yyyyMMdd"), code);
                                break;
                            }
                        }
                    }
                    txt_imagePath.Text = imagePath;
                }
                else
                {
                    imagePath = txt_imagePath.Text;
                }
                userSelected.Add(txt_imagePath.Text);
                RedisHelper.Set<List<string>>(GetUserInfo.UserNum + "Selected", userSelected, DateTime.Now.AddDays(2) - DateTime.Now);
                bakPath = string.Format(@"{0}\__bak\{1}\{2}\", imagePath.Substring(0, 2), DateTime.Now.ToString("yyyyMMdd"), imagePath.Substring(3));
                htCode["bakPath"] = bakPath;
                if (Directory.Exists(imagePath))
                {
                    ShowMsg.showMsg(listB_InfoList, "正在备份文件...");
                    PublicMethod.MoveFolderTo(imagePath, bakPath);
                    ShowMsg.showMsg(listB_InfoList, "备份完成.");
                }

                htCode["bulk"] = 0;
                Common.MonitorFile.monitorFile(imagePath, listB_InfoList, listB_ErrorList, htCode, txt_Num);
            }

        }

        /// <summary>
        /// 划分上传路径
        /// </summary>
        /// <param name="path">选择路径</param>
        /// <param name="times">上传倍速</param>
        private bool SplitFiles(string path, int times)
        {
            if (times == 1)
                return true;
            List<FileInfo> files = PublicMethod.GetPicFiles(path);
            int cnt = files.Count();
            if (cnt < times)
            {
                ShowMsg.showMsg(listB_InfoList, "路径下的文件少于您选择的次数，将以1倍速度进行上传");
                return false;
            }
            int every_files = cnt / times + 1;//每份的文件数（设定比平均值都多1，目的是最后一份肯定能分出来）
            int left = cnt;//每次分完后剩下的数，一但小于平均数，就把剩下的都给最后一份；            
            for (int i = 0; i < times; i++)
            {
                string split_path = path + (i + 1).ToString();
                if (Directory.Exists(split_path))
                {
                    PublicMethod.DelectDir(split_path);
                }
                else
                    Directory.CreateDirectory(split_path);//创建划分的文件目录；
                Thread.Sleep(1000);
                if (left < every_files)
                {
                    break;
                }
                left = left - every_files;
            }
            int split_cnt = 0;
            int split_time = 1;
            foreach (var file in files)
            {
                string split_path = path + split_time.ToString() + @"\" + file.Name;
                split_cnt++;
                if (split_time == times)
                    file.MoveTo(split_path);
                else
                {
                    if (split_cnt % every_files == 0)
                    {
                        split_time++;
                    }
                    file.MoveTo(split_path);
                }
            }
            
            return true;
        }

        private void btn_stop_Click(object sender, EventArgs e)
        {
            #region 一些显示效果
            cBox_format.Enabled = true;
            cBox_Team.Enabled = true;
            dateTimePicker1.Enabled = true;
            cBox_Workshop.Enabled = true;
            cBox_MachineNo.Enabled = true;
            txt_imagePath.Enabled = true;
            btn_imagePathSelect.Enabled = true;
            btn_start.Enabled = true;
            repeat_ToolStripMenuItem.Enabled = true;
            //bak_ToolStripMenuItem.Enabled = false;
            ckBox_bulkUpload.Enabled = true;
            cBox_UploadSpeed.Enabled = true;
            menu_ChangeUser.Enabled = true;
            VersionUpgradeToolStripMenuItem.Enabled = true;
            #endregion
            Common.MonitorFile.CloseTcpSocket(listB_InfoList, listB_ErrorList);
            txt_imagePath.Text = "";
        }

        private void btn_imagePathSelect_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                txt_imagePath.Text = dialog.SelectedPath;
            }
        }

        //自动加载关键数据

        private void AutoLoad()
        {
            var teams = ime.Teams;
            var workshops = ime.Workshops;
            List<string> teamList = new List<string>();
            List<string> workshopList = new List<string>();
            foreach (var team in teams)
            {
                teamList.Add(team.TeamName);
            }
            foreach (var workshop in workshops)
            {
                workshopList.Add(workshop.Name);
                workshopids.Add(workshop.Name, workshop.WorkshopID);//反过来存
            }
            cBox_Team.DataSource = teamList;
            cBox_Workshop.DataSource = workshopList;
            var sourceTeam = new AutoCompleteStringCollection();
            var sourceWorkshop = new AutoCompleteStringCollection();
            foreach (var name in teamList)
            {
                sourceTeam.Add(name);
            }
            foreach (var name in workshopList)
            {
                sourceWorkshop.Add(name);
            }
            cBox_Team.AutoCompleteCustomSource = sourceTeam;
            cBox_Team.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cBox_Team.AutoCompleteSource = AutoCompleteSource.CustomSource;
            cBox_Workshop.AutoCompleteCustomSource = sourceWorkshop;
            cBox_Workshop.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cBox_Workshop.AutoCompleteSource = AutoCompleteSource.CustomSource;

        }

        //根据车间自动加载其所辖机号
        private void cBox_Workshop_SelectedValueChanged(object sender, EventArgs e)
        {
            cBox_MachineNo.DataSource = null;
            string workshop = cBox_Workshop.SelectedValue.ToString();
            int workshopid = Convert.ToInt32(workshopids[workshop]);
            var machines = ime.Machines.Where(u => u.WorkshopID == workshopid);
            var sourceMachine = new AutoCompleteStringCollection();
            List<string> machineList = new List<string>();
            foreach (var machine in machines)
            {
                machineList.Add(machine.MachineNum.ToString());
            }
            cBox_MachineNo.DataSource = machineList;
        }

        private void listB_InfoList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = this.listB_InfoList.IndexFromPoint(e.X, e.Y);
            listB_InfoList.SelectedIndex = index;
            if (listB_InfoList.SelectedIndex != -1)
            {
                MessageBox.Show(listB_InfoList.SelectedItem.ToString());
            }
        }
        private void listB_ErrorList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = this.listB_ErrorList.IndexFromPoint(e.X, e.Y);
            listB_ErrorList.SelectedIndex = index;
            if (listB_ErrorList.SelectedIndex != -1)
            {
                MessageBox.Show(listB_ErrorList.SelectedItem.ToString());
            }
        }
        private void menu_ChangeUser_Click(object sender, EventArgs e)
        {
            ShowMsg.showMsg(listB_InfoList, tool_operator.Text + "，于系统时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "退出系统");
            RedisHelper.DelKey(GetUserInfo.UserID.ToString());
            Application.Exit();
            System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
        }

        private void Form_Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            RedisHelper.DelKey(GetUserInfo.UserID.ToString());
        }

        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_Config fc = new Form_Config();
            fc.Show();
        }

        private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string bak = "";
            if (string.IsNullOrEmpty(bakPath))
                bak = Path.GetPathRoot(System.Environment.CurrentDirectory) + "__bak";
            else
                bak = Path.GetPathRoot(bakPath) + "__bak";
            if (string.IsNullOrEmpty(bak))
            {
                MessageBox.Show("尚未进行过文件备份");
                ShowMsg.showMsg(listB_InfoList, "尚未进行过文件备份");
            }
            else
            {
                System.Diagnostics.Process.Start("Explorer.exe", bak);
                ShowMsg.showMsg(listB_InfoList, "打开备份文件夹");
            }
        }

        private void 清理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string bak = "";
            if (string.IsNullOrEmpty(bakPath))
                bak = Path.GetPathRoot(System.Environment.CurrentDirectory) + "__bak";
            else
                bak = Path.GetPathRoot(bakPath) + "__bak";
            if (MessageBox.Show("确定要清理吗", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                if (string.IsNullOrEmpty(bak))
                {
                    MessageBox.Show("尚未进行过文件备份");
                    ShowMsg.showMsg(listB_InfoList, "尚未进行过文件备份");
                }
                else
                {
                    if (Directory.Exists(bak))
                    {
                        PublicMethod.DelectDir(bak);
                        MessageBox.Show("清理完成！");
                        ShowMsg.showMsg(listB_InfoList, "清理完成!");
                    }
                }
            }
        }

        private void VersionUpgradeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CheckUpgrade();
        }

        private void CheckUpgrade()
        {
            string version = System.Configuration.ConfigurationManager.AppSettings["Version"].ToString();
            if (File.Exists("version.txt"))
            {
                string content = File.ReadAllText("version.txt");
                if (content.Contains("version"))
                    version = content.Split('=')[1];
                File.Delete("version.txt");
            }
            string remotePath = "upgrade";
            FtpArg args = new FtpArg();
            args.FtpServerIP = System.Configuration.ConfigurationManager.AppSettings["FtpServerIP"].ToString();
            args.FtpUserID = System.Configuration.ConfigurationManager.AppSettings["FtpUserID"].ToString();
            args.FtpPassword = System.Configuration.ConfigurationManager.AppSettings["FtpPassword"].ToString();
            string upgradeFile = FtpHelper.GetFile(remotePath, "upgrade_", args, listB_InfoList, listB_ErrorList);
            if (!string.IsNullOrEmpty(upgradeFile))
            {
                string upgrade_version = (Path.GetFileNameWithoutExtension(upgradeFile)).Split('_')[1];
                if (upgrade_version != version)
                {
                    if (MessageBox.Show("发现新版本,当前版本：" + version + "，最新版本:" + upgrade_version + ",是否立即升级？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        ShowMsg.showMsg(listB_InfoList, "发现新版本,当前版本：" + version + "，最新版本:" + upgrade_version + ",即将升级!");
                        Thread.Sleep(1000);
                        string LocalUpgradeFile = "upgrade" + DateTime.Now.ToString("yyyyMMdd") + ".zip";
                        FtpHelper.FtpDownloadBroken(upgradeFile, "upgrade", LocalUpgradeFile, true, 0, args);
                        ShowMsg.showMsg(listB_InfoList, tool_operator.Text + "，于系统时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "下载升级包成功");
                        RedisHelper.DelKey(GetUserInfo.UserID.ToString());
                        File.AppendAllText("version.txt", "[version]=" + upgrade_version);
                        string upgrade = System.Configuration.ConfigurationManager.AppSettings["Upgrade"].ToString();
                        Application.Exit();
                        System.Diagnostics.Process.Start(upgrade, "" + System.Environment.CurrentDirectory + "\\" + LocalUpgradeFile + "");
                    }

                }
                else
                {
                    ShowMsg.showMsg(listB_InfoList, "当前已经是最新版本，版本号:" + version);
                    File.AppendAllText("version.txt", "[version]=" + version);
                }
            }
        }

        private void local_repeat_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            listB_InfoList.Items.Clear();
            ShowMsg.showMsg(listB_InfoList, "正在获取本机上传的重复文件sn号码");
            try
            {
                string path = System.Environment.CurrentDirectory + "\\RepeatLogs\\" + DateTime.Now.ToString("yyyyMMdd") + "_repeat.txt";
                StreamReader sr = new StreamReader(path, System.Text.Encoding.Default);
                String line;
                int cnt = 0;
                while ((line = sr.ReadLine()) != null)
                {
                    ShowMsg.showMsg(listB_InfoList, line);
                    if (!string.IsNullOrEmpty(line))
                        cnt++;
                }
                ShowMsg.showMsg(listB_InfoList, "共计" + cnt + "条");
            }
            catch (Exception ex)
            {
                ShowMsg.showMsg(listB_InfoList, "获取失败," + ex.Message);
            }
        }

        private void All_Repeat_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            listB_InfoList.Items.Clear();
            ShowMsg.showMsg(listB_InfoList, "正在获取服务器上记录的重复文件sn号码");
            try
            {
                string remotePath = string.Format("repeatLog\\{0}_{1}_{2}_{3}_repeat.txt", DateTime.Now.ToString("yyyyMMdd"), cBox_Workshop.Text, cBox_Team.Text, cBox_MachineNo.Text);
                FtpArg args = new FtpArg();
                args.FtpServerIP = System.Configuration.ConfigurationManager.AppSettings["FtpServerIP"].ToString();
                args.FtpUserID = System.Configuration.ConfigurationManager.AppSettings["FtpUserID"].ToString();
                args.FtpPassword = System.Configuration.ConfigurationManager.AppSettings["FtpPassword"].ToString();
                string repeatFile = FtpHelper.GetFile(remotePath, "repeat.txt", args, listB_InfoList, listB_ErrorList);
                if (!string.IsNullOrEmpty(repeatFile))
                {
                    string path = System.Environment.CurrentDirectory + "\\RepeatLogs\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_repeat_ftp.txt";
                    if (File.Exists(path))
                        File.Delete(path);
                    FtpHelper.FtpDownloadBroken(repeatFile, "\\repeatLog\\", path, true, 0, args);
                    ShowMsg.showMsg(listB_InfoList, tool_operator.Text + "，于系统时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "获取本次全部重复列表");
                    StreamReader sr = new StreamReader(path, System.Text.Encoding.UTF8);
                    String line;
                    int cnt = 0;
                    while ((line = sr.ReadLine()) != null)
                    {
                        ShowMsg.showMsg(listB_InfoList, line);
                        if (!string.IsNullOrEmpty(line))
                            cnt++;
                    }
                    sr.Close();
                    ShowMsg.showMsg(listB_InfoList, "共计" + cnt + "条");
                }
            }
            catch (Exception ex)
            {
                ShowMsg.showMsg(listB_InfoList, "获取失败," + ex.Message);
            }
        }

        private void ckBox_bulkUpload_CheckedChanged(object sender, EventArgs e)
        {
            if (ckBox_bulkUpload.Checked)
                cBox_UploadSpeed.Enabled = true;
            else
                cBox_UploadSpeed.Enabled = false;
            RedisHelper.DelKey(GetUserInfo.UserNum + "Selected");
        }

        private void 查看上传报告ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txt_imagePath.Text))
            {
                ShowMsg.showMsg(listB_InfoList, "请先选择上传路径");
            }
            else
            {
                string reportFile = txt_imagePath.Text + "\\" + DateTime.Now.ToString("yyyyMMdd") + "_report.txt";
                if (File.Exists(reportFile))
                    System.Diagnostics.Process.Start(reportFile);
                else
                    ShowMsg.showMsg(listB_InfoList, "上传报告尚未生成");
            }
        }

        private void Export_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_Export fe = new Form_Export();
            fe.Show();
        }        
    }
}
